using System;
using System.Collections.Generic;
using System.Text;

namespace TextEditor
{
    public class A_TableCellAlignBottom : A_Action
    {
        public override string ActionName()
        {
            return "tablecellalignbottom";
        }

        public override bool isEnable()
        {
            return base.myOwnerDocument.GetInTable(base.myOwnerDocument.Content.CurrentElement) == null ? false : true;
        }

        public override int CheckState()
        {
            ZYTextElement element = base.myOwnerDocument.Content.CurrentElement;
            ZYTextTableCell tableCell = base.myOwnerDocument.GetInTableCell(element);
            if (tableCell != null)
            {
                return tableCell.Align == TableCellAlign.Bottom ? 1 : 0;
            }
            return -1;
        }

        public override bool UIExecute()
        {
            ZYTextElement element = base.myOwnerDocument.Content.CurrentElement;
            ZYTextTableCell tableCell = base.myOwnerDocument.GetInTableCell(element);
            tableCell.Align = TableCellAlign.Bottom;
            base.OwnerDocument.ContentChanged();
            return true;
        }
    }
}
